<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui">

	<ui:composition template="/template.xhtml">
	<ui:define name="titulo">#{locale.bemvindo}</ui:define>
	<ui:define name="body">
		<p:layout style="min-width:400px; min-height:400px; height: 340px;" id="layout">
			<p:layoutUnit position="west" resizable="false" size="500" minSize="400" maxSize="500" style="border: none; padding: 0px;">
				<p:accordionPanel rendered="#{sessionBean.usuario.id == 0}">  
	    			<p:tab title="#{locale.entrarTitulo}">
		    			<h:form>
				   			<h:panelGrid columns="2">
				   				<h:outputLabel for="email" value="#{locale.entrarEmail}:" />
				   				<p:inputText id="email" value="#{sessionBean.usuario.email}" required="true" label="#{locale.entrarEmail}">
				   					<f:validateLength minimum="6" maximum="30" />
				   					<f:validator validatorId="EmailValidator" />
				   				</p:inputText>
				   				<h:outputLabel for="senha" value="#{locale.entrarSenha}:" />
				   				<p:inputText type="password" id="senha" value="#{sessionBean.usuario.senha}" required="true" label="#{locale.entrarSenha}">
				   					<f:validateLength minimum="6" />
				   				</p:inputText>
				   				<p:commandButton value="#{locale.entrarTitulo}" actionListener="#{sessionBean.efetuarLogin}" ajax="false" update="growl" />
				   				<p:commandButton type="reset" value="#{locale.entrarReset}" />
				   			</h:panelGrid>
			    		</h:form>
	    			</p:tab>  
	    			<p:tab title="#{locale.cadastroAdminTitulo}">
		    			<h:form>
				   			<h:panelGrid columns="2">
				   				<h:outputLabel for="nome" value="#{locale.cadastroAdminNome}:" />
				   				<p:inputText id="nome" value="#{usuarioBean.admin.nome}" required="true" label="#{locale.cadastroAdminNome}">
				   					<f:validateLength minimum="6" maximum="20" />
				   					<f:validator validatorId="SpacesValidator" />
				   					<f:validator validatorId="LetrasValidator" />
				   					<f:validator validatorId="NomeExisteValidator" />
				   				</p:inputText>
				   				<h:outputLabel for="email" value="#{locale.cadastroAdminEmail}:" />
				   				<p:inputText id="email" value="#{usuarioBean.admin.email}" required="true" label="#{locale.cadastroAdminEmail}">
				   					<f:validateRequired />
				   					<f:validator validatorId="EmailValidator" />
				   					<f:validator validatorId="EmailExisteValidator" />
				   				</p:inputText>			    					
				   				<h:outputLabel for="senha" value="#{locale.cadastroAdminSenha}:" />
				   				<p:inputText type="password" id="senha" value="#{usuarioBean.admin.senha}" required="true" label="#{locale.cadastroAdminSenha}">
				   					<f:validateLength minimum="6" />
				   				</p:inputText>
				   				<p:commandButton value="#{locale.cadastroAdminBotaoCadastrar}" actionListener="#{usuarioBean.cadastrarAdmin}" ajax="false" update="growl" />
				   				<p:commandButton type="reset" value="#{locale.cadastroAdminBotaoLimpar}" />
				   			</h:panelGrid>
			    		</h:form>
				    </p:tab>
	    			<p:tab title="#{locale.cadastroUsuarioTitulo}">  
		    			<h:form>
				   			<h:panelGrid columns="2">
				   				<h:outputLabel for="nome" value="#{locale.cadastroUsuarioNome}:" />
				   				<p:inputText id="nome" value="#{usuarioBean.usuario.nome}" required="true" label="#{locale.cadastroUsuarioNome}">
				   					<f:validateLength minimum="6" maximum="20" />
				   					<f:validator validatorId="SpacesValidator" />
				   					<f:validator validatorId="LetrasValidator" />
				   					<f:validator validatorId="NomeExisteValidator" />
				   				</p:inputText>
				   				<h:outputLabel for="email" value="#{locale.cadastroUsuarioEmail}:" />
				   				<p:inputText id="email" value="#{usuarioBean.usuario.email}" required="true" label="#{locale.cadastroUsuarioEmail}">
				   					<f:validateRequired />
				   					<f:validator validatorId="EmailValidator" />
				   					<f:validator validatorId="EmailExisteValidator" />
				   				</p:inputText>			    					
				   				<h:outputLabel for="senha" value="#{locale.cadastroUsuarioSenha}:" />
				   				<p:inputText type="password" id="senha" value="#{usuarioBean.usuario.senha}" required="true" label="#{locale.cadastroUsuarioSenha}">
				   					<f:validateLength minimum="6" />
				   				</p:inputText>
				   				<p:commandButton value="#{locale.cadastroUsuarioBotaoCadastrar}" actionListener="#{usuarioBean.cadastrarUsuario}" ajax="false" update="growl" />
				   				<p:commandButton type="reset" value="#{locale.cadastroUsuarioBotaoLimpar}" />
				   			</h:panelGrid>
			    		</h:form>
				    </p:tab> 					    
				</p:accordionPanel>  
				<p:panel rendered="#{sessionBean.usuario.id != 0}" header="#{locale.welcomePanelTitulo}">
					<p class="panel-body" style="padding: 0px;">
	        			#{locale.welcomePanelOla} <span class="site-labels">#{sessionBean.usuario.nome}!</span> #{locale.welcomePanelAcesseSeu} <span class="site-labels"><a href="profile.jsf">#{locale.welcomePanelPerfil}</a></span> #{locale.welcomePanelParaEditar}!<br /><br />
	        			#{locale.welcomePanelVocePode} <span class="site-labels"><a href="main.jsf">#{locale.welcomePanelPainel}</a></span> #{locale.welcomePanelParaCriar}
	        		</p>
				</p:panel>  
	    	</p:layoutUnit>
			<p:layoutUnit position="center" style="border: none">  
    			<p:panel header="#{locale.PanelNoticiasTitulo}" style="margin-bottom: 5px;">  
	  				<h2>#{locale.PanelNoticiasAtualizacoes}!</h2>
	  				<p>
						#{locale.PanelNoticiasForamCriados} <span class="site-labels">#{systemBean.blogsQtde}</span>
						#{locale.PanelNoticiasBlogsPublicados} <span class="site-labels">#{systemBean.postsQtde}</span>
						#{locale.PanelNoticiasPosts}, <span class="site-labels">#{systemBean.comentariosQtde}</span>
						#{locale.PanelNoticiasComentarios}, <span class="site-labels">#{systemBean.usuariosQtde}</span>
						#{locale.PanelNoticiasUsuarios} <span class="site-labels">#{systemBean.adminsQtde}</span> 
						#{locale.PanelNoticiasAdminCadastrados}!			
	  				</p>
    			</p:panel>
    			<p:panel header="#{locale.PanelUltimosBlogsTitulo}">
	  				<ui:repeat var="blog" value="#{systemBean.listaUltimosBlogs}">
	  					<div class="ultimoblog">
	  						<span class="ultimosblogs-titulo">#{blog.nome}</span><br />
	  						<span class="ultimosblogs-descricao">#{blog.descricao}</span>
	  						<h:form>
		  						<span class="ultimosblogs-url">
									<p:commandLink action="#{sessionBean.exibeBlog}" ajax="false" style="margin: 0px; padding: 0px;">
										acessar &gt;
										<f:setPropertyActionListener target="#{sessionBean.selectBlog}" value="#{blog}" />
									</p:commandLink>
								</span>					
							</h:form>
							<br />	  					
	  					</div>
	  				</ui:repeat>
    			</p:panel>    			 
	    	</p:layoutUnit>
		</p:layout>
	</ui:define>
</ui:composition>
</html>